﻿/**
* Vista asociada al contenido 
* con la interfaz que muestra con perfil de usurio tipo 1(Ver Proyecto)
* en el aplicativo.
*/
Ext.define("entgpv11.view.MenuUser03", {
    extend:"Ext.form.Panel",
    alias: "widget.menuuser03",
    config: {
       type: 'fit',
		dataId:0,
		rol:'ADM'
    },
	
    initialize: function () {
      try
      {
        this.callParent(arguments);
	    var valueHidden = this.getDataId();
	    var exitButton = {
            xtype: "button",
            ui: 'decline',
            iconCls: "delete",iconMask: true,
            handler: this.onBackButtonTap,
            scope: this
        };
		var backButton = {
            xtype: "button",
            ui: "back",
           iconCls: "reply",iconMask: true,
            handler: this.onBackButtonTap,
            scope: this
        };		
        var topToolbar = {
            xtype: "toolbar",
            docked: "top",
            title: "",
            items: [
                backButton,
                { xtype: "spacer" },
                exitButton
            ]
        };
        var bottomToolbar = {
            xtype: "toolbar",
            docked: "bottom",
            items: [
                
            ]
        };
		var lblInfo ={
			xtype: 'fieldset',
			title: 'Proyectos',
			height: 80,
			instructions: 'Seleccione criterios para realizar la busqueda de proyectos',
		};
       var lblgrid ={
			xtype: 'fieldset',
			title: 'Datos',
			height: 35,
			instructions: '',
		};
        var storeListAnyo = Ext.create("entgpv11.store.Filter");
        storeListAnyo.setData([{Key:"2012",Value:"2012"},{Key:"2013",Value:"2013"},{Key:"2014",Value:"2014"},{Key:"2015",Value:"2015"}]);
        var selectAnyo = {
			    xtype: "selectfield",
			    label: "Año",
			    name: "sAnyoId",
			    store: storeListAnyo,
			    displayField:"Value",
			    valueField:"Key"
		};
          
		var storeListMes = Ext.create("entgpv11.store.Filter");
        storeListMes.setData([{Key:"Ninguno",Value:"Todos"},{Key:"Enero",Value:"Enero"},{Key:"Febrero",Value:"Febrero"},{Key:"Marzo",Value:"Marzo"},{Key:"Abril",Value:"Abril"},
        {Key:"Mayo",Value:"Mayo"},{Key:"Junio",Value:"Junio"},{Key:"Julio",Value:"Julio"},{Key:"Agosto",Value:"Agosto"},
        {Key:"Septiembre",Value:"Septiembre"},{Key:"Octubre",Value:"Octubre"},{Key:"Noviembre",Value:"Noviembre"},{Key:"Diciembre",Value:"Diciembre"},
        ]);
        var selectMes= {
			    xtype: "selectfield",
			    label: "Mes",
			    name: "sMesId",
			    store: storeListMes,
			    displayField:"Value",
			    valueField:"Key"
		};
        var btnSeek = {
            xtype: "button",
            text: 'Buscar',
            ui: 'action',
            handler: this.onBtnSearch,
            scope: this
        };
        var tplgrid_1 = [
              '<table  border="0" cellspacing="0" cellpadding="0">',
              '<tr>',
              '<td class="first-head">{Mes}</td>',
              '<td class="child-head">{Ingreso}</td>',
              '<td class="child-head">{Egreso}</td>',
              '<td class="child-head">{Saldo}</td>',
              '</tr>',
              '</table>'
       ];
       var tplgrid_2 = [
              '<table  border="0" cellspacing="0" cellpadding="0">',
              '<tr>',
              '<td class="first-child">{Mes}</td>',
              '<td>{Ingreso}</td>',
              '<td>{Egreso}</td>',
              '<td class="last-child">{Saldo}</td>',
              '</tr>',
              '</table>'
          ];
        
       var headgrid={
            xtype: 'list',
            id:'gridExcelHead',
            layout: 'hbox',
            scroll: false,
            align: 'top',
            minHeight :  (window.innerHeight*5)/100,
            //height:  (window.innerHeight*5)/100,
            store: {
                fields: ["Mes","Ingreso","Egreso","Saldo"],
                data: [
                    {Mes:"",Ingreso:"",Egreso:"",Saldo:""}
                ]
            },
          
            itemTpl:tplgrid_1
           
        };  
       var grid = {
                xtype: 'list',
                id:'gridExcel',
                grouped: false,
                store: Ext.getStore("ExcelDropBox"),
                height:  (window.innerHeight*70)/100,
			    loadingText:"Cargando datos...",
                itemTpl:tplgrid_2,
                emptyText: '<div class="emptytext">Sin datos para vizualizar</div>'
            };
         
          this.add([
			         lblInfo,
					{ xtype: "fieldset",
						items: [
						          selectAnyo,
						          selectMes,
								  btnSeek,
						          {
                                        xtype: 'panel',
                                        html: '<hr class="lingrid">'
                                  },
								  headgrid,  
						          {
                                        xtype: 'panel',
                                        html: '<hr class="lingrid">'
                                  },
						          grid
                            ]
					}
			]);
		
        } catch (ex) {
            APP_GLOBAL.SetLog('MenuUser01.initialize::' + ex);
        }
    },
	onBackButtonTap: function () {
        //console.log("backButtonTap");
        this.fireEvent("backButtonTapCommand", this);
    },
	onBtnSearch: function () {
     this.fireEvent("btnSearchCommand", this);
	
   
    } 
});

